{% extends 'base.html' %}

{% block main %}
    {% if error_msg %}
        <p>{{ error_msg }}</p>
    {% endif %}

    {% for article in article_list %}
        <article class="post post-{{ article.id }}">
            <header class="entry-header">
                <h1 class="entry-title">
                    <a href="{{ article.get_absolute_url }}">{{ article.title }}</a>
                </h1>
                <div class="entry-meta">
                    <span class="post-category"><a href="javascript:void(0)">{{ article.category.name }}</a></span>
                    <span class="post-date"><a href="javascript:void(0)"><time class="entry-date"
                                                              datetime="{{ article.created_time }}">{{ article.created_time }}</time></a></span>
                    <span class="post-author"><a href="javascript:void(0)">{{ article.author }}</a></span>
                    <span class="comments-link"><a href="javascript:void(0)">{{ article.comment_set.count }} 评论</a></span>
                    <span class="views-count"><a href="javascript:void(0)">{{ article.views }} 阅读</a></span>
                </div>
            </header>
            <div class="entry-content clearfix">
                <p>{{ article.summary }}</p>
{#                <div class="read-more cl-effect-14">#}
{#                    <a href="{{ article.get_absolute_url }}" class="more-link">继续阅读 <span#}
{#                            class="meta-nav">→</span></a>#}
{#                </div>#}
            </div>
        </article>
    {% empty %}
        <div class="no-article">暂时还没有发布的文章!</div>
    {% endfor %}


    {#    {% if is_paginated %}#}
    {#        <div class="pagination-simple">#}
    {#            <!-- 如果当前页还有上一页，显示一个上一页的按钮 -->#}
    {#        {% if page_obj.has_previous %}#}
    {#            <a href="?page={{ page_obj.previous_page_number }}">上一页</a>#}
    {#        {% endif %}#}
    {#        <!-- 显示当前页面信息 -->#}
    {#        <span class="current">第 {{ page_obj.number }} 页 / 共 {{ paginator.num_pages }} 页</span>#}
    {#        <!-- 如果当前页还有下一页，显示一个下一页的按钮 -->#}
    {#        {% if page_obj.has_next %}#}
    {#            <a href="?page={{ page_obj.next_page_number }}">下一页</a>#}
    {#        {% endif %}#}
    {#        </div>#}
    {#    {% endif %}#}


    {% if is_paginated %}
        <div class="pagination-simple">
            {% if page_obj.has_previous %}
                <a href="?page={{ page_obj.previous_page_number }}">上一页</a>
            {% endif %}
            {% if first %}
                <a href="?page=1">1</a>
            {% endif %}
            {% if left %}
                {% if left_has_more %}
                    <span>...</span>
                {% endif %}
                {% for i in left %}
                    <a href="?page={{ i }}">{{ i }}</a>
                {% endfor %}
            {% endif %}
            <a href="?page={{ page_obj.number }}" style="color: red">{{ page_obj.number }}</a>
            {% if right %}
                {% for i in right %}
                    <a href="?page={{ i }}">{{ i }}</a>
                {% endfor %}
                {% if right_has_more %}
                    <span>...</span>
                {% endif %}
            {% endif %}
            {% if last %}
                <a href="?page={{ paginator.num_pages }}">{{ paginator.num_pages }}</a>
            {% endif %}
            {% if page_obj.has_next %}
                <a href="?page={{ page_obj.next_page_number }}">下一页</a>
            {% endif %}
        </div>
    {% endif %}

{% endblock main %}
